/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entities;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author roycalderon
 */
@Entity
@Table(name = "bookBorrowing")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "BookBorrowing.findAll", query = "SELECT b FROM BookBorrowing b"),
    @NamedQuery(name = "BookBorrowing.findByIdbookBorrowing", query = "SELECT b FROM BookBorrowing b WHERE b.idbookBorrowing = :idbookBorrowing"),
    @NamedQuery(name = "BookBorrowing.findByDate", query = "SELECT b FROM BookBorrowing b WHERE b.date = :date")})
public class BookBorrowing implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idbookBorrowing")
    private Integer idbookBorrowing;
    @Column(name = "date")
    @Temporal(TemporalType.TIMESTAMP)
    private Date date;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "bookBorrowing", fetch = FetchType.LAZY)
    private List<BookList> bookListList;
    @JoinColumn(name = "Employee_idEmployee", referencedColumnName = "idEmployee")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Employee employeeidEmployee;
    @JoinColumn(name = "Student_idStudent", referencedColumnName = "idStudent")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Student studentidStudent;

    public BookBorrowing() {
    }

    public BookBorrowing(Integer idbookBorrowing) {
        this.idbookBorrowing = idbookBorrowing;
    }

    public Integer getIdbookBorrowing() {
        return idbookBorrowing;
    }

    public void setIdbookBorrowing(Integer idbookBorrowing) {
        this.idbookBorrowing = idbookBorrowing;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    @XmlTransient
    public List<BookList> getBookListList() {
        return bookListList;
    }

    public void setBookListList(List<BookList> bookListList) {
        this.bookListList = bookListList;
    }

    public Employee getEmployeeidEmployee() {
        return employeeidEmployee;
    }

    public void setEmployeeidEmployee(Employee employeeidEmployee) {
        this.employeeidEmployee = employeeidEmployee;
    }

    public Student getStudentidStudent() {
        return studentidStudent;
    }

    public void setStudentidStudent(Student studentidStudent) {
        this.studentidStudent = studentidStudent;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idbookBorrowing != null ? idbookBorrowing.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof BookBorrowing)) {
            return false;
        }
        BookBorrowing other = (BookBorrowing) object;
        if ((this.idbookBorrowing == null && other.idbookBorrowing != null) || (this.idbookBorrowing != null && !this.idbookBorrowing.equals(other.idbookBorrowing))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entities.BookBorrowing[ idbookBorrowing=" + idbookBorrowing + " ]";
    }
    
}
